<template>
  <el-input-number v-model="sort" v-bind="inputAttr" :disabled="Disabled" />
</template>
<script>
// 排序输入组件
export default {
  name: 'Sort',
  inject: {
    elForm: {
      default: {}
    }
  },
  props: {
    value: '',
    // 是否禁用
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      sort: ''
    }
  },
  watch: {
    value: {
      immediate: true,
      handler (n) {
        this.sort = n
      }
    },
    sort: {
      handler (n) {
        this.$emit('input', n)
        this.$emit('change', n)
      }
    }
  },
  computed: {
    Disabled () {
      return this.elForm.disabled || this.disabled
    },
    inputAttr () {
      return {
        min: 1,
        max: 127,
        precision: 0,
        placeholder: '请输入序号',
        ...this.$attrs
      }
    }
  }
}
</script>
